<template>
	<view class="content poRel">
		<view class="wid100" style="height: 410rpx;background-color: #37BCC3;">
			<view style="height: 72rpx;"></view>
			<view class="textCen coFFF">
				<view class="foSi30" style="line-height: 30rpx;">可提现收益</view>
				<view class="fowe600 mar-top40" style="font-size: 70rpx;line-height: 70rpx;">¥{{rewards}}</view>
				<view class="dis disAl disJuC borRad40 bacFFF foSi40 hei80 mar" 
					style="margin-top: 50rpx;color: #37BCC3;width: 251rpx;" @click="tanchuang(true)">提现</view>
			</view>
		</view>
		<view class="wid85 mar dis disAl fowe600 foSi40" style="height: 120rpx;">收益明细</view>
		<view class="wid100" style="border-bottom: 1rpx dashed #DCDCDC;"></view>
		<scroll-view style="height: calc(100vh - 532rpx);" class="wid100" scroll-y="true" @scrolltolower="lower">
			<view v-if="list.length == 0" class="wid85 mar fowe800 foSi35 mar-top30">
				<view style="height: 50rpx;"></view>
				<view class="dis disJuC">
					<image src="../../static/zanwu2.png" style="width: 400rpx;height: 300rpx;"></image>
				</view>
				<view class="textCen mar-top20" style="color: #868686;">暂无数据</view>
			</view>
			<block v-for="(item,index) in list" :key="index">
				<view style="height: 1rpx;"></view>
				<view class="wid85 mar dis disAl disJuB" style="margin-top: 50rpx;">
					<view >
						<view class="foSi35 fowe600">推广佣金</view>
						<view class="mar-top20 foSi25" style="color: #737373;">{{item.createtime}}</view>
					</view>
					<view class="foSi40 fowe600" style="color: #37BCC3;">+{{item.divide_money}}</view>
				</view>
			</block>
			<view style="height: 50rpx;"></view>
		</scroll-view>
		<view class="tc" v-if="txtc == true">
			<view class="" @click="tanchuang(false)" style="width:40rpx; height: 40rpx;text-align: center; line-height: 40rpx; position: absolute; right: 12%;top: 37%; z-index: 101;">
				X
			</view>
			<view class="jvzhong borRad30">
				<view class="mar-left30 mar-top30">
					提现金额
				</view>
				<input type="digit" v-model="money" class="borRad30" style="border: 1px solid #808080; width: 80%; height: 50rpx; margin:20rpx auto; padding: 0 10rpx;" />
				<!-- <view class="" style="width: 80%;margin: 0 auto;">
					<radio-group @change="chang" style="margin-top: 10%;">
						<label v-for="(item,index) in radioGroup" :key="item" style="margin: 10%;">
							<radio :value="index" :checked="index==activeRadio" />{{item}}
						</label>
					</radio-group>
				</view> -->
				<view class="borRad30 foSi30" style="width: 125px; height: 60rpx; background: #37BCC3; color: #fff; text-align: center; line-height: 60rpx; margin: 30rpx auto;" @click="tixian">提现</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url: this.global.url,
				list: [],
				divide_money:0,
				rewards:0,
				txtc:false,
				// radioGroup:['余额','微信'],
				// activeRadio:0,
				money:''
			}
		},
		onLoad() {
			var that = this;
			that.lists()
		},
		methods: {
			tixian(){
				var that = this;
				console.log(that.money);
				console.log(that.divide_money);
				if(that.money == 0 || that.money == ""){
					uni.showToast({
						title:'请输入提现金额',
						icon:'none',
						position:'top'
					})
					return;
				}
				if(that.money>that.divide_money){
					uni.showToast({
						title:'提现金额不可大于可提现收益',
						icon:'none',
						position:'top'
					})
					return;
				}
				uni.request({
					url: that.global.url + '/api/qianyu_petrol/gasstation_pay_take_money',
					method: "POST",
					header: {
						'site-id': that.global.site_id,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {
						amount:that.money,
						// type:that.activeRadio
					},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							that.lists()
							
							that.txtc = false
							uni.showToast({
								title:'提现成功',
								icon:'none',
								duration: 1000
							})
						}else{
							uni.showToast({
								title:result.msg,
								icon:'none',
								duration: 1000
							})
						}
					}
				})
				
			},
			chang(e) {
				console.log(e);
				this.activeRadio = e.detail.value;  //选中按钮的value值
				console.log(this.activeRadio);
			},
			lists(){
				var that = this;
				uni.request({
					url: that.global.url + '/api/qianyu_petrol/gasstation_divide_list',
					method: "POST",
					header: {
						'site-id': that.global.site_id,//自定义请求头信息
						'token': uni.getStorageSync('token')
					},
					data: {},
					success(res) {
						let result = res.data
						console.log(result)
						if (result.code == 1) {
							that.list = result.data.parent_list
							that.divide_money = result.data.divide_money
							that.rewards = result.data.rewards
						}
					}
				})
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				})
			},
			tanchuang(a){
				var that = this;
				that.txtc = a
			}
		}
	}
</script>

<style>
	.content {}
	.tc{
		position: absolute;
		left: 0;
		top: 0;
		width: 100vw;
		height: 100vh;
		background: rgba(0, 0, 0, 0.5);
		z-index: 10;
	}
	.jvzhong{
		position: absolute;
		top: 50%;
		left:50%;
		transform: translate(-50%,-50%);
		background: #fff;
		width: 80%;
		height: 400rpx;
		z-index: 100;
	}
</style>